package com.iot.controller;

import cn.dev33.satoken.annotation.SaCheckHttpBasic;
import cn.dev33.satoken.annotation.SaCheckOr;
import cn.dev33.satoken.util.SaResult;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @className: SwaggerContrller
 * @author: IceZhang
 * @date: 2025/7/8 19:18:39
 * @Version: 1.0
 * @description:
 */
@RestController
@Api(tags = "swagger")
public class SwaggerContrller {

    @SaCheckOr(
            httpBasic = @SaCheckHttpBasic(account = "sa:123456")
    )
    @GetMapping("/swagger")
    public SaResult test3(HttpServletResponse response) throws IOException {
//        SaHttpBasicUtil.check("sa:123456");
        // 重定向到 Swagger UI
        response.sendRedirect("/swagger-ui.html");
        return null; // 已经通过 response 发送了重定向，这里返回 null
    }

}
